"""
进程间通信
"""
from multiprocessing import Process
from multiprocessing import Queue
from time import sleep


def cut_vegetable(qu):
    vegetables = ["白菜", "胡萝卜", "西红柿", "西兰花", "辣椒", "油麦菜", "大蒜"]
    for vegetable in vegetables:
        sleep(0.5)
        if not qu.full():
            qu.put(vegetable)
            print("{}切完了".format(vegetable))
        else:
            print("{}->装不下了菜篮子装满了".format(vegetable))


def cook(qu):
    while not qu.empty():
        print("开始抄{}".format(qu.get()))


if __name__ == '__main__':
    qu = Queue(5)
    p1 = Process(target=cut_vegetable, args=(qu,))
    p2 = Process(target=cook, args=(qu,))

    p1.start()
    p1.join()

    p2.start()
    p2.join()

    print("*******************")
